var e = require;
var t = module;
var n = exports;
Object.defineProperty(n, "__esModule", {value: !0}), (n.playerCoin = n.coinData = void 0);
var _ = e("Excelkeyvalue"),
    a = e("Excellevel1"),
    w = e("index"),
    s = e("user-data"),
    C = e("player-info");
n.coinData = function () {};
(o.prototype.getIsCoinFirst = function () {
    return this.isCoinFirst;
}),
    (o.prototype.getCoinMaxCount = function () {
        return this.coinMaxCount;
    }),
    (o.prototype.getCoinMaxNumber = function () {
        return this.coinMaxNumber;
    }),
    (o.prototype.setCoinMaxNumber = function (e) {
        e > this.coinMaxNumber && (this.coinMaxNumber = e);
    }),
    (o.prototype.resetCoinMaxNumber = function () {
        this.coinMaxNumber = 0;
    }),
    (o.prototype.getIsFirst = function () {
        var e = s.userData.getLocalData().coinFirst;
        return null == e || e;
    }),
    (o.prototype.setIsFirst = function (e) {
        s.userData.setLocalData({coinFirst: e});
    }),
    (o.prototype.initCellData = function () {
        if (this.getIsFirst()) {
            this.setCoinMaxNumber(this.initMinNumber), (this.isCoinFirst = !0);
            for (var e = _.default.GetLine(1).defaultCells, t = 1; t < e + 1; t++) {
                for (var n = [], o = 0; o < this.coinMaxCount; o++) {
                    var i,
                        r = a.default.GetLine(o + 1);
                    r["place" + t] && (((i = new C.saveCoinData()).num = Number(r["place" + t])), n.unshift(i));
                }
                C.playerInfo.setCellsByIdx(t, n);
            }
            this.setIsFirst(!1);
        } else this.checkCellData();
    }),
    (o.prototype.getInitCellData = function () {
        var e = C.playerInfo.getLevel();
        this.resetCoinMaxNumber(), this.setCoinMaxNumber(this.initMinNumber);
        for (
            var t = 6 * (e - 1) + 1,
                n = [t, 1 + t, 2 + t, 3 + t],
                o = [t, 1 + t, 2 + t, 3 + t],
                i = [t, 1 + t, 2 + t, 3 + t],
                r = _.default.GetLine(1).defaultCells,
                a = new Array(r),
                s = 0;
            s < r;
            s++
        )
            a[s] = s + 1;
        for (var a = w.shuffleArr(a), c = new Map(), s = 0; s < a.length; s++) {
            var l = a[s];
            if (s < 2) {
                for (var u = w.randomInt(2, 5), p = new Array(u), h = 0; h < u; h++) {
                    var d = new C.saveCoinData();
                    (d.num = n[s]), (p[h] = d);
                }
                c.set(l, p);
            } else {
                var f = o;
                f.length < 2 && (f = i);
                for (
                    var m = w.randomInt(1, f.length) - 1,
                        y = f.splice(m, 1)[0],
                        m = w.randomInt(1, f.length) - 1,
                        m = f.splice(m, 1)[0],
                        g = ((p = new Array(4)), [y, m, m, m]),
                        v = 0;
                    v < 4;
                    v++
                ) {
                    var b = new C.saveCoinData();
                    (b.num = g[v]), 0 < v && 1 < e && (b.isUn = !0), (p[v] = b);
                }
                c.set(l, p);
            }
        }
        c.forEach(function (e, t) {
            C.playerInfo.setCellsByIdx(t, e);
        });
    }),
    (o.prototype.checkCellData = function () {
        var e,
            t = s.userData.getLocalData().cell_data;
        if (!t)
            return (
                w.platform.trackEvent("error", {message: "cell_data null", type: "invalid cell data"}),
                void C.playerInfo.restartData()
            );
        if (t.constructor !== Object)
            return (
                w.platform.trackEvent("error", {message: "cell_data no Object", type: "invalid cell data"}),
                void C.playerInfo.restartData()
            );
        for (e in t) {
            var n,
                o = t[e];
            if (o.constructor !== Array)
                return (
                    w.platform.trackEvent("error", {message: "data no Array", type: "invalid cell data"}),
                    void C.playerInfo.restartData()
                );
            for (n in o) {
                var i,
                    r = o[n];
                if ("object" != typeof r)
                    return (
                        w.platform.trackEvent("error", {message: "value2 no Object", type: "invalid cell data"}),
                        void C.playerInfo.restartData()
                    );
                for (i in r) {
                    var a = r[i];
                    "num" === i || "isUn" === i
                        ? "num" === i && "number" != typeof a
                            ? (w.platform.trackEvent("error", {message: "num no number", type: "invalid cell data"}),
                              C.playerInfo.restartData())
                            : "isUn" === i &&
                              a &&
                              "boolean" != typeof a &&
                              (w.platform.trackEvent("error", {message: "isUn no boolean", type: "invalid cell data"}),
                              C.playerInfo.restartData())
                        : (w.platform.trackEvent("error", {message: "key2 no right", type: "invalid cell data"}),
                          C.playerInfo.restartData());
                }
            }
        }
        console.log("checkCellData...22.....", !0);
    }),
    (e = o);
function o() {
    (this.coinMaxCount = _.default.GetLine(1).mergeNeedNum),
        (this.coinMaxNumber = 0),
        (this.isCoinFirst = !1),
        (this.initMinNumber = 4);
}
n.playerCoin = new e();
